
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>构建工具配置说明 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="appji-zhu-kuang-jia-shuo-ming.html" />
    
    
    <link rel="prev" href="fa-bu-yun-xing.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    前言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="jie-shao.html">
            
                <a href="jie-shao.html">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="xu-yao-kan-de-kuang-jia-wen-dang.html">
            
                <a href="xu-yao-kan-de-kuang-jia-wen-dang.html">
            
                    
                    需要看的框架文档
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="an-zhuang.html">
            
                <a href="an-zhuang.html">
            
                    
                    安装与调试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="kai-fa-huan-jing-yi-lai-mo-kuai-shuo-ming.html">
            
                <a href="kai-fa-huan-jing-yi-lai-mo-kuai-shuo-ming.html">
            
                    
                    开发环境依赖模块说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="xiang-mu-mu-lu-shuo-ming.html">
            
                <a href="xiang-mu-mu-lu-shuo-ming.html">
            
                    
                    项目目录说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="fa-bu-yun-xing.html">
            
                <a href="fa-bu-yun-xing.html">
            
                    
                    发布运行程序
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6" data-path="gou-jian-gong-ju-pei-zhi.html">
            
                <a href="gou-jian-gong-ju-pei-zhi.html">
            
                    
                    构建工具配置说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="appji-zhu-kuang-jia-shuo-ming.html">
            
                <a href="appji-zhu-kuang-jia-shuo-ming.html">
            
                    
                    App技术框架说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="apppei-zhi-yi-ji-qi-ta-fang-fa.html">
            
                <a href="apppei-zhi-yi-ji-qi-ta-fang-fa.html">
            
                    
                    App配置以及其他方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="zu-jian-shuo-ming.html">
            
                <a href="zu-jian-shuo-ming.html">
            
                    
                    组件说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="appye-wu-luo-ji-shuo-ming.html">
            
                <a href="appye-wu-luo-ji-shuo-ming.html">
            
                    
                    App业务逻辑说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="appda-bao-ji-jie-kou-diao-yong.html">
            
                <a href="appda-bao-ji-jie-kou-diao-yong.html">
            
                    
                    App打包及接口调用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="chang-jian-wen-ti.html">
            
                <a href="chang-jian-wen-ti.html">
            
                    
                    常见问题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="chang-jian-wen-ti/muikuang-jia-yu-fa-wen-ti.html">
            
                <a href="chang-jian-wen-ti/muikuang-jia-yu-fa-wen-ti.html">
            
                    
                    mui框架语法问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="chang-jian-wen-ti/qi-ta-wen-ti.html">
            
                <a href="chang-jian-wen-ti/qi-ta-wen-ti.html">
            
                    
                    其他问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >构建工具配置说明</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="gulpfilejs-&#x914D;&#x7F6E;&#x8BF4;&#x660E;">gulpfile.js &#x914D;&#x7F6E;&#x8BF4;&#x660E;</h2>
<p>gulp&#x5DE5;&#x5177;&#x914D;&#x7F6E;&#xFF0C;&#x81EA;&#x52A8;&#x6267;&#x884C;&#x6253;&#x5305;&#x538B;&#x7F29;&#x4EE3;&#x7801;&#x7B49;&#x547D;&#x4EE4;</p>
<pre><code>var autoprefixer = require(&apos;autoprefixer&apos;),
    combiner = require(&apos;stream-combiner2&apos;), //&#x6574;&#x5408; streams &#x6765;&#x5904;&#x7406;&#x9519;&#x8BEF;
    gulp = require(&apos;gulp&apos;),
    named = require(&apos;vinyl-named&apos;),
    path = require(&apos;path&apos;),
    plugins = require(&apos;gulp-load-plugins&apos;)(),
    webpack = require(&apos;webpack&apos;),
    webpackStream = require(&apos;webpack-stream&apos;);

var dest = &apos;build&apos;, proj = &apos;.&apos;;

gulp.task(&apos;build&apos;, function() {//build&#x4EFB;&#x52A1;,&#x6267;&#x884C;styles&#x3001;scriptsRelease&#x3001;htmls&#x3001;resources&#x5BF9;&#x5E94;&#x6837;&#x5F0F;&#xFF0C;js&#x6587;&#x4EF6;&#xFF0C;html&#x6587;&#x4EF6;&#xFF0C;&#x9759;&#x6001;&#x8D44;&#x6E90;&#x56FE;&#x7247;&#x7B49;&#x6253;&#x5305;&#x4EFB;&#x52A1;
    gulp.start(&apos;styles&apos;,&apos;scriptsRelease&apos;,&apos;htmls&apos;, &apos;resources&apos;);
});

gulp.task(&apos;dev&apos;, [&apos;watch&apos;], function() {//&#x76D1;&#x5BDF;&#x4EFB;&#x52A1;&#xFF0C;&#x4EE3;&#x7801;&#x6539;&#x52A8;&#x6267;&#x884C;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x6253;&#x5305;
    gulp.start(&apos;styles&apos;,&apos;scripts&apos;,&apos;htmls&apos;, &apos;resources&apos;);
});

gulp.task(&apos;xiaodou&apos;, function() {//&#x5176;&#x4ED6;&#x4E1A;&#x52A1;&#x4EFB;&#x52A1;
    proj = &apos;../cheways_xiaodou&apos;;
    dest = &apos;../cheways_xiaodou/build&apos;;
    gulp.start(&apos;copy&apos;,&apos;styles&apos;,&apos;scripts&apos;,&apos;htmls&apos;, &apos;resources&apos;);
});

gulp.task(&apos;copy&apos;,function(){
    gulp.src(&apos;common/**/*.*&apos;)
        .pipe(plugins.changed(proj+&apos;/common&apos;))
        .pipe(gulp.dest(proj+&apos;/common&apos;));
    gulp.src(&apos;lib/**/*.*&apos;)
        .pipe(plugins.changed(proj+&apos;/lib&apos;))
        .pipe(gulp.dest(proj+&apos;/lib&apos;));
    gulp.src(&apos;index.html&apos;)
        .pipe(plugins.changed(proj))
        .pipe(gulp.dest(proj));
});

gulp.task(&apos;watch&apos;,function(){
    gulp.watch(&apos;src/**/*.@(css|styl)&apos;,[&apos;styles&apos;]);
    gulp.watch(&apos;src/**/*.@(html|pug)&apos;,[&apos;htmls&apos;]);
    gulp.watch(&apos;src/**/*.@(png|jpg|ico|svg|gif)&apos;,[&apos;resources&apos;]);
    gulp.watch(proj+&apos;/special/*.styl&apos;, [&apos;styles&apos;]);
});

gulp.task(&apos;styles&apos;,function(){//styles&#x547D;&#x4EE4;&#x5904;&#x7406;css&#x6837;&#x5F0F;&#x6587;&#x4EF6;
    gulp.src(&apos;src/**/*.css&apos;)
        .pipe(plugins.changed(dest))
        .pipe(plugins.postcss([ autoprefixer({cascade: false}) ]))
        .pipe(plugins.cleanCss())
        .pipe(gulp.dest(dest));
    gulp.src(&apos;src/**/*.styl&apos;)
        .pipe(plugins.changed(dest,{extension:&apos;.css&apos;}))
        .pipe(plugins.stylus({paths: [proj+&apos;/special&apos;]}))
        .pipe(plugins.postcss([ autoprefixer({cascade: false}) ]))
        .pipe(gulp.dest(dest));
    gulp.src(&apos;common/common.styl&apos;)
        .pipe(plugins.changed(proj+&apos;/common&apos;,{extension:&apos;.css&apos;}))
        .pipe(plugins.stylus({paths: [proj+&apos;/special&apos;]}))
        .pipe(gulp.dest(proj+&apos;/common&apos;));
});

gulp.task(&apos;scriptsRelease&apos;,function(){//scriptsRelease&#x547D;&#x4EE4;&#x5904;&#x7406;js&#x6587;&#x4EF6;&#x538B;&#x7F29;
    gulp.src(&apos;src/**/*.js&apos;)
        .pipe(named(function(file) {
            return file.relative.slice(0, -path.extname(file.path).length)
        }))
        .pipe(webpackStream({
            output: {
                publicPath: &apos;../&apos;,
                chunkFilename: &apos;[name].bundle.js&apos;,
            },
            resolve: {
                alias: {
                    &apos;vue$&apos;: &apos;vue/dist/vue.common.js&apos;,
                    &apos;cheways-vue$&apos;: &apos;../../nopack/js/cheways-vue.js&apos;,
                    &apos;special&apos;: path.resolve(proj, &apos;special&apos;),
                }
            },
            module: {
                rules: [
                    {test: /\.vue$/, loader: &apos;vue-loader&apos;, options: {
                        postcss: [require(&apos;autoprefixer&apos;)()]
                    }},
                    {test: /\.js$/, exclude: /node_modules/, loader: &quot;babel-loader&quot; },
                ]
            },
            plugins: [
                new webpack.DllReferencePlugin({
                    context: __dirname,
                    manifest: require(&apos;./lib/vendors-manifest.json&apos;)
                })
            ],
        }, webpack))
        .pipe(plugins.uglify())
        .pipe(gulp.dest(dest));
});

gulp.task(&apos;scripts&apos;,function(){
    gulp.src(&apos;src/**/*.js&apos;)
        .pipe(named(function(file) {
            return file.relative.slice(0, -path.extname(file.path).length)
        }))
        .pipe(webpackStream({
            output: {
                publicPath: &apos;../&apos;,
                chunkFilename: &apos;[name].bundle.js&apos;,
            },
            resolve: {
                alias: {
                    &apos;vue$&apos;: &apos;vue/dist/vue.common.js&apos;,
                    &apos;cheways-vue$&apos;: &apos;../../nopack/js/cheways-vue.js&apos;,
                    &apos;special&apos;: path.resolve(proj, &apos;special&apos;),
                }
            },
            module: {
                rules: [
                    {test: /\.vue$/, loader: &apos;vue-loader&apos;, options: {
                        postcss: [require(&apos;autoprefixer&apos;)()]
                    }},
                    {test: /\.js$/, exclude: /node_modules/, loader: &quot;babel-loader&quot; },
                ]
            },
            plugins: [
                new webpack.DllReferencePlugin({
                    context: __dirname,
                    manifest: require(&apos;./lib/vendors-manifest.json&apos;)
                })
            ],
            watch: true,
        }, webpack))
        .pipe(gulp.dest(dest));
});

gulp.task(&apos;htmls&apos;,function(){//htmls&#x547D;&#x4EE4;&#x5904;&#x7406;html&#x6587;&#x4EF6;&#x538B;&#x7F29;&#x7B49;
    gulp.src(&apos;src/**/*.html&apos;)
        .pipe(plugins.changed(dest))
        .pipe(plugins.htmlmin())
        .pipe(gulp.dest(dest));
    var combined = combiner.obj([
        gulp.src(&apos;src/**/*.pug&apos;),
        plugins.changed(dest,{extension:&apos;.html&apos;}),
        plugins.pug({}),
        gulp.dest(dest)
    ]);
    combined.on(&apos;error&apos;, console.error.bind(console));
});

gulp.task(&apos;resources&apos;,function(){//resources&#x547D;&#x4EE4;&#x5904;&#x7406;&#x8D44;&#x6E90;&#x56FE;&#x7247;
    gulp.src(&apos;src/**/*.@(png|jpg|ico|svg|gif)&apos;)
        .pipe(plugins.changed(dest))
        .pipe(gulp.dest(dest));
});

gulp.task(&apos;dist&apos;, function() {
    var androidProject = &apos;C:/Users/XL/workspace/cheways-common3/assets/apps/HelloH5/www/&apos;
    gulp.src(&apos;build/**/*.*&apos;)
        .pipe(plugins.changed(androidProject+&apos;build&apos;))
        .pipe(gulp.dest(androidProject+&apos;build&apos;))
    gulp.src(&apos;lib/**/*.*&apos;)
        .pipe(plugins.changed(androidProject+&apos;lib&apos;))
        .pipe(gulp.dest(androidProject+&apos;lib&apos;))
    gulp.src(&apos;special/**/*.*&apos;)
        .pipe(plugins.changed(androidProject+&apos;special&apos;))
        .pipe(gulp.dest(androidProject+&apos;special&apos;))
    gulp.src(&apos;manifest.json&apos;)
        .pipe(plugins.changed(androidProject+&apos;www&apos;))
        .pipe(gulp.dest(androidProject+&apos;www&apos;))
})

gulp.task(&apos;distas&apos;, function() {
    var androidProject = &apos;C:/Users/XL/AndroidStudioProjects/cheways-common3/app/src/main/assets/apps/HelloH5/www&apos;
    gulp.src(&apos;build/**/*.*&apos;)
        .pipe(plugins.changed(androidProject+&apos;build&apos;))
        .pipe(gulp.dest(androidProject+&apos;build&apos;))
    gulp.src(&apos;lib/**/*.*&apos;)
        .pipe(plugins.changed(androidProject+&apos;lib&apos;))
        .pipe(gulp.dest(androidProject+&apos;lib&apos;))
    gulp.src(&apos;special/**/*.*&apos;)
        .pipe(plugins.changed(androidProject+&apos;special&apos;))
        .pipe(gulp.dest(androidProject+&apos;special&apos;))
    gulp.src(&apos;manifest.json&apos;)
        .pipe(plugins.changed(androidProject+&apos;www&apos;))
        .pipe(gulp.dest(androidProject+&apos;www&apos;))
})
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="fa-bu-yun-xing.html" class="navigation navigation-prev " aria-label="Previous page: 发布运行程序">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="appji-zhu-kuang-jia-shuo-ming.html" class="navigation navigation-next " aria-label="Next page: App技术框架说明">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"构建工具配置说明","level":"1.6","depth":1,"next":{"title":"App技术框架说明","level":"1.7","depth":1,"path":"appji-zhu-kuang-jia-shuo-ming.md","ref":"appji-zhu-kuang-jia-shuo-ming.md","articles":[]},"previous":{"title":"发布运行程序","level":"1.5","depth":1,"path":"fa-bu-yun-xing.md","ref":"fa-bu-yun-xing.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"gou-jian-gong-ju-pei-zhi.md","mtime":"2017-11-09T21:18:38.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2017-11-11T03:51:05.960Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

